﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace WorldClock.Converters
{
    public class HourToDegree : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int minutes = System.Convert.ToInt32(value);
            int m;
            int h = Math.DivRem(minutes, 60, out m)%12;
            int degree = System.Convert.ToInt32( (h * 30) +(m * 0.5));
            return degree;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
